<?php
/**
 * [商网通 System] Copyright swtshop.cn
 * QQ: 1170787711
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied');
class shop_uqcms extends control
{
    function open_time()
    {
        $spid = !empty($_GET['spid']) ? $_GET['spid'] : error_json('店铺不能为空');
        $tquery = $this->db->get_all("select * from " . table('shop_service_time') . " where shop_id = " . $spid);
        if ($tquery) {
            foreach ($tquery as $v) {
                $tarr['t1'] = $v['time1'];
                $tarr['t2'] = $v['time2'];
                $tarr['t3'] = $v['time3'];
                $tarr['t4'] = $v['time4'];
                $tarr['t11'] = $this->daytime($v['time1']);
                $tarr['t22'] = $this->daytime($v['time2']);
                $tarr['t33'] = $this->daytime($v['time3']);
                $tarr['t44'] = $this->daytime($v['time4']);
                $time[$v['week']] = $tarr;
            }
            $data['time'] = $time;
            $data['now_diff'] = time() - strtotime(date('Ymd'));
            $data['error'] = '0';
            echo json_encode($data);
        } else {
            error_json();
        }
    }
    private function daytime($time_diff)
    {
        $total = strtotime(date('Ymd')) + $time_diff;
        return date("H:i", $total);
    }
}